package com.books.controller.elasticsearch;

/**
 * @author ZhouRui
 * @title: 码上就来
 * @projectName cbstore-spring-boot
 * @description: TODO
 * @date 2021/10/3014:40
 */
import com.books.service.essearch.RecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
public class RecommendController {

    @Autowired(required = false)
    private RecommendService recommendService;

    /**
     * 基于用户的推荐
     * @param userId 用户id
     * @param num 推荐数量
     * @return
     */
    @RequestMapping("recommendByUser")
    public List<Integer> getRecommendItemsByUser(Integer userId, Integer num){
        List<Integer> items= recommendService.getRecommendItemsByUser(userId,num);
        return items;
    }
    /**
     * 基于内容的推荐
     * @param userId 用户id
     * @param itemId 商品id
     * @param num 推荐数量
     * @return
     */
    @RequestMapping("recommendByItem")
    public List<Integer> getRecommendItemsByItem(Integer userId,Integer itemId, Integer num){
        List<Integer> items= recommendService.getRecommendItemsByItem(userId,itemId, num);
        return items;
    }
}
